package com.example.demo.controller;

import com.example.demo.threadPool.ExecutorWrapper;
import com.example.demo.threadPool.ThreadWrapper;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;
import java.util.concurrent.ExecutorService;

/**
 * @Description:
 * @author: fanfan
 * @date: 2019/3/18 9:51
 */
@Slf4j
@RestController
public class TestController {
//    private static ThreadPoolExecutorMdcWrapper execute = new ThreadPoolExecutorMdcWrapper();
    ExecutorService service = ExecutorWrapper.newFixedThreadPool(10);
    @RequestMapping("/test")
    public void test(){
        log.info("111");
        log.info("222");
        Map<String, String> copyOfContextMap = MDC.getCopyOfContextMap();
        new ThreadWrapper(new Runnable() {
            @Override
            public void run() {
                log.info("333");
            }
        }).start();
        Map<String, String> copyOfContextMap1 = MDC.getCopyOfContextMap();
        service.execute(new Runnable() {
            @Override
            public void run() {
                log.info("444");
            }
        });
    }
}
